function pigrid = startvalgeneratorMultiStep(knotvec,pi,scalefactor,upperlinwt,uppercurvfactor,steps,stepsize,uppertailparams,display)


if nargin<8
    display = 0 ;
end

if scalefactor<0 || scalefactor>1
    error('StartValGenerator:InvalidInputs','The variable "scalefactor" must be strictly between 0 and 1...')
end

if upperlinwt<0 || upperlinwt>1
    error('StartValGenerator:InvalidInputs','The variable "upperlinwt" must be strictly between 0 and 1...')
end

if uppercurvfactor<0 || uppercurvfactor>1
    error('StartValGenerator:InvalidInputs','The variable "uppercurvfactor" must be strictly between 0 and 1...')
end

if mod(steps,1)~=0 || steps<=0
    error('StartValGenerator:InvalidInputs','The variable "steps" must be a positive integer...')
end

if stepsize<0 || stepsize>1
    error('StartValGenerator:InvalidInputs','The variable "stepsize" must be strictly between 0 and 1...')
end


pigrid = startvalgenerator(knotvec,pi,scalefactor,   upperlinwt,    uppercurvfactor, uppertailparams,  0) ;
for s=1:steps-1
    scalefactor     = scalefactor*stepsize ;
    upperlinwt      = upperlinwt*stepsize ;
    uppercurvfactor = uppercurvfactor*stepsize ;
    temp   = startvalgenerator(knotvec,pi,scalefactor,   upperlinwt,    uppercurvfactor, uppertailparams,  0) ;
    %%%%The following gets rid of columns of temp that already appear in pigrid
    dropflag = zeros(length(temp(1,:)),1);
    for ii=1:length(temp(1,:))
        test1=(temp(:,ii)==pigrid);
        for jj=1:length(test1(1,:))
            if sum(test1(:,jj))==12
                dropflag(ii)=1;
            end
        end
    end
    temp(:,dropflag==1) = [] ;
    pigrid = [pigrid temp] ; %#ok
    clear temp dropflag ii jj test1
end


if display==1
    figure
    hold on
    testdom = linspace(knotvec(1),knotvec(end),2000)' ;
    for ii=1:length(pigrid(1,:))
        C       = BsplineEval3(knotvec,pigrid(:,ii),testdom) ;
        plot(testdom,C) ;
    end
end










